using System.Collections.Generic;
using System.ComponentModel;
using System.Workflow.ComponentModel;
using TechHeadBrothers.IO;

namespace TechHeadBrothers.Workflows.Activities
{
    public partial class ZipFiles : Activity
    {
        public static DependencyProperty ManifestPathProperty =
            DependencyProperty.Register("ManifestPath", typeof (string), typeof (ZipFiles));

        public static DependencyProperty VideoPathProperty =
            DependencyProperty.Register("VideoPath", typeof (string), typeof (ZipFiles));

        public static DependencyProperty ZipPathProperty =
            DependencyProperty.Register("ZipPath", typeof (string), typeof (ZipFiles));

        /// <summary>
        /// Initializes a new instance of the <see cref="ZipFiles"/> class.
        /// </summary>
        public ZipFiles()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the video path.
        /// </summary>
        /// <value>The video path.</value>
        [Description("Path of the video to upload")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string VideoPath
        {
            get { return ((string) (GetValue(VideoPathProperty))); }
            set { SetValue(VideoPathProperty, value); }
        }

        /// <summary>
        /// Gets or sets the manifest path.
        /// </summary>
        /// <value>The manifest path.</value>
        [Description("Manifest path of the video")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string ManifestPath
        {
            get { return ((string) (GetValue(ManifestPathProperty))); }
            set { SetValue(ManifestPathProperty, value); }
        }

        /// <summary>
        /// Gets or sets the zip path.
        /// </summary>
        /// <value>The zip path.</value>
        [Description("Zip path to upload")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string ZipPath
        {
            get { return ((string) (GetValue(ZipPathProperty))); }
            set { SetValue(ZipPathProperty, value); }
        }


        /// <summary>
        /// Called by the workflow runtime to execute an activity.
        /// </summary>
        /// <param name="executionContext">The <see cref="T:System.Workflow.ComponentModel.ActivityExecutionContext"></see> to associate with this <see cref="T:System.Workflow.ComponentModel.Activity"></see> and execution.</param>
        /// <returns>
        /// The <see cref="T:System.Workflow.ComponentModel.ActivityExecutionStatus"></see> of the run task, which determines whether the activity remains in the executing state, or transitions to the closed state.
        /// </returns>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            List<string> files = new List<string>(2);
            files.Add(VideoPath);
            files.Add(ManifestPath);
            ZipUtilities.SaveZip(files, ZipPath, 1);

            return base.Execute(executionContext);
        }
    }
}